﻿using System.Windows;
using System.Windows.Controls;
using Microsoft.Surface.Presentation.Controls;
using MTBrainStorm.ViewModels;

namespace MTBrainStorm.Views
{
    /// <summary>
    /// Interaction logic for VirtualKeyboardKey.xaml
    /// </summary>
    public partial class VirtualKeyboardKey : SurfaceButton
    {
        public VirtualKeyboardKeyViewModel Key
        {
            get { return (VirtualKeyboardKeyViewModel) GetValue(KeyProperty); }
            set
            {
                SetValue(KeyProperty, value);
                DataContext = Key;
            }
        }

        public static readonly DependencyProperty KeyProperty = DependencyProperty.Register(
            "Key",
            typeof (VirtualKeyboardKeyViewModel),
            typeof (VirtualKeyboardKey),
            new FrameworkPropertyMetadata(new PropertyChangedCallback(UpdateKey)));

        private static void UpdateKey(DependencyObject source, DependencyPropertyChangedEventArgs e)
        {
            ((VirtualKeyboardKey)source).Key = (VirtualKeyboardKeyViewModel) e.NewValue;
        }

        public VirtualKeyboardKey()
        {
            InitializeComponent();
        }
    }
}
